package com.bugstack.domain.activity.service.quota.policy.impl;

import com.bugstack.domain.activity.model.aggregate.CreateOrderAggregate;
import com.bugstack.domain.activity.model.valobj.OrderStateVO;
import com.bugstack.domain.activity.reopsitory.IActivityRepository;
import com.bugstack.domain.activity.service.quota.policy.ITradePolicy;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * @Author: czb
 * @Description: TODO
 * @DateTime: 2025/4/16 15:48
 **/
@Component("rebate_no_pay_trade")
public class RebateNoPayTradePolicy implements ITradePolicy {

    private final IActivityRepository repository;

    public RebateNoPayTradePolicy(IActivityRepository repository) {
        this.repository = repository;
    }


    @Override
    public void trade(CreateOrderAggregate createOrderAggregate) {
        createOrderAggregate.setState(OrderStateVO.completed);
        createOrderAggregate.getActivityOrderEntity().setPayAmount(BigDecimal.ZERO);
        repository.doSaveNoPayOrder(createOrderAggregate);
    }
}
